package com.dailyblue.java.standard.network.bio;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class 服务端 extends Thread {

    private Scanner scanner = new Scanner(System.in);

    @Override
    public void run() {
        try {
            ServerSocket ss = new ServerSocket(8899);
            Socket socket = ss.accept();
            System.out.println("客户端连接成功");
            // 服务器的发送
            OutputStream out = socket.getOutputStream();
            InputStream in = socket.getInputStream();
            // 启动发送线程
            new 发送(out, true).start();
            new 接收(in).start();
        } catch (Exception e) {
            System.out.println(e.getMessage() + "1112121");
        }
    }

    public static void main(String[] args) {
        new 服务端().start();
    }
}
